package com.wangxiaoxuan.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 王小轩
 * @version 1.0
 * 公共返回对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {

    private long code;
    private String message;
    private Object obj;

    /**
     * 成功返回结果
     * @return
     */
    public static RespBean success(){
        return new RespBean(ResBeanEnum.SUCCESS.getCode(),ResBeanEnum.SUCCESS.getMessage(),null);
    }

    public static RespBean success(Object obj){
        return new RespBean(ResBeanEnum.SUCCESS.getCode(),RespBean.success().getMessage(),obj);
    }

    /**
     * 失败
     * @param resBeanEnum
     * @return
     */
    public static RespBean error(ResBeanEnum resBeanEnum){
        return new RespBean(resBeanEnum.getCode(),resBeanEnum.getMessage(),null);
    }
    
    public static RespBean error(ResBeanEnum resBeanEnum,Object obj){
        return new RespBean(resBeanEnum.getCode(),resBeanEnum.getMessage(),obj);
    }
}
